package com.cqupt.scanning.security.config;

import com.cqupt.scanning.security.utils.ResponseUtil;
import com.cqupt.scanning.system.utils.result.R;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Data: 2021/7/12 10:54
 * @Author: 宋宝梁
 */
public class UnauthorizedEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
        ResponseUtil.out(response, R.error().message("Unauthorized"));
    }
}
